<div class="repoShow">
    <ng-container *ngIf="repository">
        <h3>Repository {{repository.name}}</h3>
        <div class="repoShow-container" *ngIf="repository && vcsProject">
            <nz-alert nzType="info" [nzDescription]="infoMsg" nzShowIcon></nz-alert>
            <ng-template #infoMsg>
                Make sure that user "{{vcsProject.auth.username}}" can read the target repository.
            </ng-template>
            <form nz-form>
                <nz-form-item>
                    <nz-form-label nzSpan="3">ID</nz-form-label>
                    <nz-form-control>{{repository.id}}</nz-form-control>
                </nz-form-item>
                <nz-form-item>
                    <nz-form-label nzSpan="3">Clone URL</nz-form-label>
                    <nz-form-control>{{repository.clone_url}}</nz-form-control>
                </nz-form-item>
                <nz-form-item>
                    <nz-form-label nzSpan="3">Added</nz-form-label>
                    <nz-form-control>{{repository.created}} by {{repository.created_by}}</nz-form-control>
                </nz-form-item>
            </form>
            <div class="analyses">
                <h3>Repository analyses <i (click)="loadAnalyses()" nz-icon nzType="sync" [nzSpin]="loadingAnalysis" nzTheme="outline" class="pointing"></i> </h3>
                <nz-table [nzLoading]="loadingAnalysis" [nzData]="repoAnalyses" [nzPageSize]="10" nzSize="small" #analysesTable>
                    <thead>
                    <th nzWidth="50px">Status</th>
                    <th>Date</th>
                    <th nzWidth="330px">ID</th>
                    <th>Branch</th>
                    <th>CDS User</th>
                    <th>Files</th>
                    <th>Error</th>
                    </thead>
                    <tbody>
                    <tr *ngFor="let a of analysesTable.data">
                        <td><app-status-icon [status]="a.status" nz-tooltip="{{a.status}}"></app-status-icon></td>
                        <td><span nz-tooltip="{{a.last_modified}}">{{a.last_modified | amTimeAgo}}</span></td>
                        <td>{{a.id}}</td>
                        <td><span nz-tooltip="{{'Commit: ' + a.commit}}">{{a.branch}}</span></td>
                        <td>{{a.data.cds_username}}</td>
                        <td>
                            <ng-container *ngIf="a?.data?.entities?.length > 0">
                                {{a.data.entities.length + ' files found'}}
                                <i nz-icon nzType="eye" nzTheme="outline" class="pointing" nz-popover [nzPopoverContent]="fileTmpl" nzPopoverTrigger="click"></i>
                            </ng-container>
                            <ng-template #fileTmpl>
                                <ul class="nopoint">
                                    <li *ngFor="let f of a.data.entities">
                                        <div class="container">
                                            <app-status-icon [status]="f.status" ></app-status-icon>
                                            <div class="label">{{f.path + f.file_name}}</div>
                                        </div>
                                    </li>
                                </ul>
                            </ng-template>
                        </td>
                        <td><div class="error">{{a.data.error}}</div></td>
                    </tr>
                    </tbody>
                </nz-table>
            </div>
        </div>
        <div class="footer">
            <div class="buttons">
                <button nz-button nzDanger nzType="primary" [nzLoading]="loading" nz-popconfirm
                        nzPopconfirmTitle="Are you sure you want to remove this repository ?" (nzOnConfirm)="removeRepositoryFromProject()"
                        nzPopconfirmPlacement="topRight">
                    Remove
                </button>
            </div>
        </div>
    </ng-container>
    <ng-container *ngIf="!repository">
        <nz-spin nzTip="Loading repository"></nz-spin>
    </ng-container>
</div>

